<div class="clear mainbox-title-container">

	<div>
		<?php echo CHtml::link('&laquo; '.t('Back').':&nbsp;'.t('Usergroups'), array('/user/manageGroup'), array('class' => 'back-link strong')) ?>
	</div>

	<h1 class="mainbox-title"><?php echo t('Edit Usergroup') ?></h1>

	<div class="mainbox-title-bg">&nbsp;</div>
</div>

<?php Yii::app()->clientScript->registerScriptFile(bu() .'/js/tabs.js'); ?>

<?php $this->renderPartial('//common/tabs_header', array(
	'tabs' => array(
		'general' => t('General Information'),
		'privileges' => t('Privileges'),
	),
	'active_tab' => getParam('selected_section') ? getParam('selected_section') : 'general',
)) ?>

<div class="cm-tabs-content">

	<input type="hidden" name="selected_section" id="selected_section" value="general">

	<?php $form = $this->beginWidget('CActiveForm', array(
		'id' => 'usergroup_form',
		'enableClientValidation' => true,
		'focus' => array($model, 'usergroup'),
		'htmlOptions' => array(
			'class' => 'form',
		),
	)); ?>

	<?php echo CHtml::errorSummary($model); ?>

	<div id="content_general" style="display: block;">
		<fieldset>

			<div class="form-field row">
				<?php echo $form->labelEx($model, 'usergroup'); ?>
				<?php echo $form->textField($model, 'usergroup', array('size' => 32, 'maxlength' => 128, 'class' => 'input-text')); ?>
				<?php echo $form->error($model, 'usergroup'); ?>
			</div>

			<div class="form-field row">
				<?php echo $form->labelEx($model, 'status'); ?>
				<div class="select-field">
					<?php echo $form->radioButtonList($model, 'status', array(
						'A' => t('Active'),
						'D' => t('Unactive'),
					), array(
						'separator' => '&nbsp;&nbsp;',
						'class' => 'radio',
					)); ?>
				</div>
			</div>

		</fieldset>

	</div>

	<div id="content_privileges" class="" style="display: none;">
		<table class="table" width="100%" cellpadding="0" cellspacing="0" border="0">

		<tr>
			<th width="1%" class="table-group-checkbox">
				<input type="checkbox" class="checkbox cm-check-items" title="Check / uncheck all" value="Y" name="check_all">
			</th>
			<th width="100%" colspan="5"><?php echo t('Permission') ?></th>
		</tr>

		<?php foreach ($privileges as $section => $_privileges) {

			echo '<tr class="table-group-header"><td colspan="6">'.t($section).'</td></tr>';

			$loop = ceil(count($_privileges) / 3) * 3;

			for ($i = 0; $i < $loop; $i++) : ?>
				<?php if ( $i % 3 == 0 ) : ?>
				<tr class="object-group-elements">
				<?php endif; ?>

				<?php if ( isset($_privileges[$i]) ) : ?>
					<?php $pri = $_privileges[$i]; ?>
					<td width="1%" class="table-group-checkbox">
						<input type="checkbox" id="set_privileges_<?php echo $pri->privilege; ?>" class="checkbox cm-item" value="Y" <?php echo in_array($pri->privilege, $model->group_privileges) ? 'checked="checked"' : '' ?> name="set_privileges[<?php echo $pri->privilege; ?>]">
					</td>
					<td width="33%"><label for="set_privileges_<?php echo $pri->privilege; ?>"><?php echo $pri->description; ?></label></td>
				<?php else : ?>
					<td colspan="2">&nbsp;</td>
				<?php endif; ?>

				<?php if ( $i %3 == 2 ) : ?>
				</tr>
				<?php endif; ?>

			<?php endfor;

		} ?>

		</table>
	</div>

	<!--	<p class="select-field notify-customer cm-toggle-button" style="display: block;">
		<input type="checkbox" id="notify_customer" class="checkbox" value="Y" name="notify_customer">
		<label for="notify_customer">Thông báo cho thành viên</label>
	</p>-->

	<div class="buttons-container buttons-bg cm-toggle-button">
		<span class="submit-button cm-button-main">
			<?php echo CHtml::submitButton($model->isNewRecord ? t('Create') : t('Save')); ?>
		</span>
		&nbsp;<?php echo t('or') ?>&nbsp;&nbsp;
		<?php echo CHtml::link(t('Cancel'), array('/user/manageGroups'), array('class' => 'underlined tool-link')) ?>
	</div>

</div>

<?php $this->endWidget(); ?>